import React from 'react';
import { ProForm, ProFormDigit, ProFormText } from '@ant-design/pro-components';
import { getWordFun } from '@/services/ant-design-pro/reportApi';

const Report = () => {
  const onFinish = async (values) => {
    let res = await getWordFun(values.age, values.name);
    // 接收流文件数据并下载
    const blob = new Blob([res], {
      type: res.type,
    });
    const link = document.createElement('a');
    link.href = URL.createObjectURL(blob);
    link.download = 'test.docx';
    link.click();
  };
  return (
    <>
      <ProForm title="新建表单" onFinish={onFinish} style={{ width: 600 }}>
        <ProFormText name="name" label="名称" placeholder="请输入名称" />
        <ProFormDigit type={'number'} name="age" label="年龄" placeholder="请输入年龄" />
      </ProForm>
    </>
  );
};

export default Report;
